#******************************************************************
#
# Copyright 2015 Samsung Electronics All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Import('env')
gtest_env = SConscript('#extlibs/gtest/SConscript')
rcs_common_test_env = gtest_env.Clone()

rcs_common_test_env.PrependUnique(CPPPATH = [
    '#/extlibs/hippomocks/hippomocks',
    '#/resource/csdk/include',
    '#/resource/csdk/stack/include',
    '#/resource/include',
    '#/resource/oc_logger/include',
    '#/service/resource-encapsulation/include/',
    '../include',
    '../../utils/include',
    "../../expiryTimer/include",
    "../../expiryTimer/src",
])

rcs_common_test_env.PrependUnique(LIBS = [
    'oc',
    'octbstack',
    'oc_logger',
    'connectivity_abstraction',
    'coap',
    'rcs_common'
])

rcs_common_test_src = [
    rcs_common_test_env.Glob('*.cpp'),
    '../../expiryTimer/unittests/ExpiryTimerTest.cpp',
    '../../utils/include/UnitTestHelperWithFakeOCPlatform.cpp'
]

rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)
Alias("rcs_common_test", rcs_common_test)
rcs_common_test_env.AppendTarget('rcs_common_test')

if rcs_common_test_env.get('TEST') == '1':
    rcs_common_test_env.AppendUnique(CPPDEFINES=['HIPPOMOCKS_ISSUE'])
    from tools.scons.RunTest import run_test
    run_test(rcs_common_test_env,
             'service_resource-encapsulation_src_common_primitiveResource_unittests_rcs_common_test.memcheck',
             'service/resource-encapsulation/src/common/primitiveResource/unittests/rcs_common_test',
             rcs_common_test)
